package offer;

public class offer16 {
}
class Solution16 {
    public static double myPow(double x, int n) {
        if(x==0) return 0;
        if(n==0&&x!=0) return 1;
        double res= x;
        if(n>0)
        {
            for (int i = 1; i < n; i++) {
                res = x*res;
            }

        }
        if(n<0)
        {
            for (int i = 1; i <=-(n+1) ; i++) {
                res = x*res;
            }
            res = 1/res;
        }
    return res;

    }

    public static void main(String[] args) {
        double x =2;
        int n =-2147483648;
        myPow(x,n);
    }
}